""" http://coding.derkeiler.com/Archive/Python/comp.lang.python/2005-12/msg02777.html """
import os, sys

def getMacAddress(): 
    if sys.platform == 'win32': 
        for line in os.popen("ipconfig /all"): 
            if line.lstrip().startswith('Physical Address'): 
                mac = line.split(':')[1].strip().replace('-',':') 
                break 
    else: 
        for line in os.popen("/sbin/ifconfig"): 
            if line.find('Ether') > -1: 
                mac = line.split()[4] 
                break 
    return mac

def main():
    print(getMacAddress())
    
if __name__ == '__main__':
    main()

